package com.xlobo.api.bill.service;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.json.JSONObject;

import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;

public class AddInitBillCall extends YmatouAutoTestCall{

	private static String opurl ="/api/Bill/AddInitBill";
	
	public AddInitBillCall() {
		super(EnvSetup.getSystemUrl("bill_api"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	
	
	
	
	/**
	 * 测试接口是否正常
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
		try{
			
//			new AddInitBillCall().callAndGetReturnData();
			
			new AddInitBillCall();
			AddInitBillCall.addInitBill("testaccount1", "100", "1", "上海市", "上海市", "浦东新区", "267", 2);
		
				
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
	
	


	/**
	 * 创建面单 （匹配清关&配送供应商用）
	 * @param OperatorName 用户id
	 * @param LogisticId 分拨中心
	 * @param LineTypeId 1个人件 3电商件 9奶粉专线
	 * @param Province 收件人省
	 * @param City 收件人市
	 * @param District 收件人区
	 * @param CategoryId 规格id
	 * @param BillThirdPartType 渠道类型 2洋码头
	 * @return
	 * @throws Exception
	 */
	public static JSONObject addInitBill(String OperatorName , String LogisticId , String LineTypeId , String Province ,String City ,String District ,
			String CategoryId , int BillThirdPartType) throws  Exception {
		
		new warmup().callService();
		
		Map<String,Object> updateMap = new HashMap<String,Object>();
		updateMap.put("OperatorName", OperatorName);
		updateMap.put("BusinessNo", UUID.randomUUID());
		updateMap.put("LogisticId", LogisticId);
		updateMap.put("LineTypeId", LineTypeId);
		updateMap.put("BillReceiverInfo->Province", Province);
		updateMap.put("BillReceiverInfo->City", City);
		updateMap.put("BillReceiverInfo->District", District);
		updateMap.put("BillCategoryList[0]->CategoryId", CategoryId);
		updateMap.put("BillThirdPartType", BillThirdPartType);

		JSONObject  result = new AddInitBillCall().callAndGetReturnData(updateMap);
				
		return result;		
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
}
